package test;

import java.net.URI;
import java.net.URISyntaxException;
import hu.gbalage.owlforms.OWLFormsManager;
import hu.gbalage.owlforms.api.Field;
import hu.gbalage.owlforms.api.Form;

public class InitOWLForms {

	/**
	 * @param args
	 * @throws URISyntaxException 
	 */
	public static void main(String[] args) throws URISyntaxException {
		OWLFormsManager manager = new OWLFormsManager();
		
		manager.loadOntology(InitOWLForms.class.getResource("/test/ontology/szocpont.owl").toURI());
		manager.loadOntology(InitOWLForms.class.getResource("/test/ontology/szoctam.owl").toURI());
		
		/*OWLClass cls = manager.getDataFactory().getOWLClass(URI.create("http://hu.gbalage.owlforms/examples/szoctam.owl#Hallgato"));
		
		Set<OWLCardinalityRestriction<?,?>> crs = manager.getHelper().getProperties(cls);
		
		for(OWLCardinalityRestriction<?,?> cr : crs){
			System.out.println(cr.getProperty()+": "+cr.getCardinality());
		}*/
		
		URI uri = URI.create("http://hu.gbalage.owlforms/examples/szoctam.owl#Szoctam_hallgato");
		
		Form form = manager.getFactory().createForm(uri);
		
		printForm(0,form);
		
	}

	public static String spaces(int d){
		String result = "";
		for(int i=0;i<d;i++) result+=" ";
		return result;
	}
	
	public static void printForm(int d, Form form){
		String p = spaces(d);
		System.out.println(p+"<"+form.getURI()+">");
		for(Field f : form.listFields()){
			System.out.println(p+" "+f.getURI());
			if (f.isComplex())
				printForm(d+2,f.asComplexField().getContainedForm()[0]);
		}
	}
	
}
